View Javadoc

1   /***
2    * @version $Revision: 1.1 $
3    */
4   package uba.db.sql.interpreter;
5   
6   import uba.db.ar.AttributeDef;
7   import uba.db.ar.Tupla;
8   import uba.db.ar.TuplaDef;
9   
10  public class NullQueryPlan implements SentenceQueryPlan {
11  
12  	private boolean hasNotifiedError;
13  
14  	private Tupla tuplaToInform;
15  
16  	/*
17  	 * @see uba.db.sql.interpreter.SentenceQueryPlan#startExecution()
18  	 */
19  	public void startExecution() {
20  		hasNotifiedError = false;
21  		tuplaToInform = errorTuple();
22  	}
23  
24  	/*
25  	 * @see uba.db.sql.interpreter.SentenceQueryPlan#hasMoreResults()
26  	 */
27  	public boolean hasMoreResults() {
28  		return (!hasNotifiedError);
29  	}
30  
31  	/*
32  	 * @see uba.db.sql.interpreter.SentenceQueryPlan#nextTuple()
33  	 */
34  	public Tupla nextTuple() {
35  		return tuplaToInform;
36  	}
37  
38  	/***
39  	 * @return
40  	 */
41  	private Tupla errorTuple() {
42  		TuplaDef def = new TuplaDef();
43  		def.addDefinition(new AttributeDef("Error"));
44  		Tupla errorTuple = new Tupla(def);
45  		errorTuple.set(1, "Función no implementada.");
46  		hasNotifiedError = true;
47  		return errorTuple;
48  	}
49  
50  	/*
51  	 * @see uba.db.sql.interpreter.SentenceQueryPlan#planDetail()
52  	 */
53  	public String planDetail() {
54  		return "";
55  	}
56  
57  	/*
58  	 * @see uba.db.sql.interpreter.SentenceQueryPlan#tuplaDefinition()
59  	 */
60  	public TuplaDef tuplaDefinition() {
61  		if (tuplaToInform == null)
62  			startExecution();
63  		return tuplaToInform.tuplaDefinition();
64  	}
65  
66  }